package com.hxf.dao.user.impl;

import org.springframework.stereotype.Repository;

import com.hxf.common.PublicUtil;
import com.hxf.dao.BaseDaoImpl;
import com.hxf.dao.user.AppUserDao;
import com.hxf.dto.AppUserDto;
import com.hxf.dto.ReturnData;
import com.hxf.exception.DaoLevelException;

@Repository("appUserDao")
public class AppUserDaoImpl extends BaseDaoImpl implements AppUserDao {
	
	public ReturnData<AppUserDto> findByAppUser(AppUserDto appUserDto, int targetPage, int pageSize)throws DaoLevelException{
		String sql = "";
		if(PublicUtil.isNotNullAndEmpty(appUserDto.getUserName())){
			sql += " and userName like '%"+appUserDto.getUserName().trim()+"%'";
		}
		
		if(PublicUtil.isNotNullAndEmpty(appUserDto.getUserPhone())){
			sql += " and userPhone like '"+appUserDto.getUserPhone().trim()+"'" ;
		}
		
		if(PublicUtil.isNotNull(appUserDto.getParentId())){
			sql += " and parentId = " + appUserDto.getParentId();
		}
		return super.findBy(" from AppUserDto where 1=1 " + sql, targetPage, pageSize);
	}

}
